import time
# 定义装饰器1
def remind(func):
    def inner():
        print("我睡觉了-start", time.time())
        func()
        print("我起床了-end", time.time())

    return inner


# 定义装饰器2
def study(func):
    def inner():
        print("我要敲代码啦-start", time.time())
        func()
        print("我要敲代码啦-end", time.time())

    return inner


# 谁近谁先装饰
@study  # step2
@remind  # step1
def sleep():
    import random
    print("睡眠中。。。")
    num = random.randint(1, 5)
    time.sleep(num)
    print("睡眠中。。。%d" % num)


sleep()

print("-----------")


# 【NO】谁离被装饰的函数最近，谁就先去装饰函数
# 谁近谁先装饰
@remind  # step2
@study  # step1
def sleep2():
    import random
    print("睡眠中。。。")
    num = random.randint(1, 5)
    time.sleep(num)
    print("睡眠中。。。%d" % num)


sleep2()
